<template>
  <div class="teml">
    <nav-bar title="新闻列表"></nav-bar>
    <span>{{ss}}</span>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="news in newsList" :key="news.id">
        <router-link :to="{name:'newsDetail',params:{newId:news.id} }">
          <img class="mui-media-object mui-pull-left" src="../../assets/logo.png">
          <div class="mui-media-body">
            <span v-text="news.title"></span>
            <div class="news-desc">
              <p>点击数:{{news.click}}</p>
              <p>发表时间:{{news.add_time| convertTime}}</p>
            </div>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  data () {
    return {
      newsList: [],
      ss: [
        { id: 1, num: 0 },
        { id: 2, num: 0 },
        { id: 3, num: 0 }
      ]
    }
  },
  mounted () {
    this.$ajax.get('./getNewsList')
      .then(res => {
        this.newsList = res.data.newsList
      })
      .catch(err => {
        console.log('获取数据失败', err)
      })
  },
  created () {
    this.ss.some((item, i) => {
      if (item.id === 2) {
        this.ss.splice(i, 1)
        return true
      }
    })
  }
}
</script>
<style scoped>
.mui-media-body p {
  color: #0bb0f5;
}

.news-desc p:nth-child(1) {
  float: left;
}

.news-desc p:nth-child(2) {
  float: right;
}
.mui-media-body {
  text-align: left;
}
</style>
